package cn.yujiago.activiti.controller;

import cn.yujiago.activiti.dto.FinanceBillVO;
import cn.yujiago.activiti.dto.ResponseEntity;
import cn.yujiago.activiti.service.SQJFLCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/sqjflc")
public class SQJFLCController {

    @Autowired
    private SQJFLCService sqjflcService;

    @PostMapping("/startProcessInstance")
    @ResponseBody
    public ResponseEntity startProcessInstance(FinanceBillVO financeBillVO) {
        return sqjflcService.startProcessInstance(financeBillVO);
    }

    @GetMapping("/auditByTaskId")
    @ResponseBody
    public ResponseEntity auditByTaskId(@RequestParam("taskId") String taskId) {
        ResponseEntity result = sqjflcService.auditByTaskId(taskId);
        return result;
    }

    // 办理任务
    @PostMapping("/submitTask")
    @ResponseBody
    public ResponseEntity submitTask(FinanceBillVO financeBillVO) {
        ResponseEntity result = sqjflcService.saveSubmitTask(financeBillVO);
        return result;
    }

    // 通过实例ID和业务ID获取详情
    @GetMapping("/detailByPIIdAndFBId")
    @ResponseBody
    public ResponseEntity detailByPIIdAndFBId(@RequestParam("processInstanceId") String processInstanceId, @RequestParam("financeBillId") String financeBillId) {
        ResponseEntity result = sqjflcService.detailByPIIdAndFBId(processInstanceId, financeBillId);
        return result;
    }
}
